fix assertion failure by creating the line data, but not validating it at
authorHavoc Pennington <hp@redhat.com>
Tue, 29 Jan 2002 04:55:48 +0000 (04:55 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Tue, 29 Jan 2002 04:55:48 +0000 (04:55 +0000)
2002-01-25  Havoc Pennington  <hp@redhat.com>

        * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
        failure by creating the line data, but not validating it at this
        stage. Also, remove old code related to the "bogus newline" mess
        that removed all tags from the last char in the buffer if you
        tried to delete it.
        (_gtk_text_line_data_new): put this here and prepend underscore,
        remove from gtktextlayout.c

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextbtree.c
gtk/gtktextbtree.h
gtk/gtktextlayout.c

index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 077785d5ca4f9c673cce8c846d9bbc81097058f1..267ca71ff6d3d09ab59c0c18f1d80e4d2fe652bb 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-25  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
+       failure by creating the line data, but not validating it at this
+       stage. Also, remove old code related to the "bogus newline" mess
+       that removed all tags from the last char in the buffer if you
+       tried to delete it.
+       (_gtk_text_line_data_new): put this here and prepend underscore,
+       remove from gtktextlayout.c
+
 Mon Jan 28 19:57:39 2002  Owen Taylor  <otaylor@redhat.com>
 
        * modules/input/imhangul.c modules/input/imhangul-defs.h
index 155ed8692105218e3690b03ef4ccbfb6052d0f90..66964803137d9d91fdef0e28ad990105ac078a92 100644 (file)
@@ -548,7 +548,7 @@ _gtk_text_btree_segments_changed (GtkTextBTree *tree)
 
 void
 _gtk_text_btree_delete (GtkTextIter *start,
-                       GtkTextIter *end)
+                        GtkTextIter *end)
 {
   GtkTextLineSegment *prev_seg;             /* The segment just before the start
                                              * of the deletion range. */
@@ -575,64 +575,6 @@ _gtk_text_btree_delete (GtkTextIter *start,
   if (gtk_debug_flags & GTK_DEBUG_TEXT)
     _gtk_text_btree_check (tree);
   
-  {
-    /* FIXME this code should no longer be required */
-    /*
-     * The code below is ugly, but it's needed to make sure there
-     * is always a dummy empty line at the end of the text.  If the
-     * final newline of the file (just before the dummy line) is being
-     * deleted, then back up index to just before the newline.  If
-     * there is a newline just before the first character being deleted,
-     * then back up the first index too, so that an even number of lines
-     * gets deleted.  Furthermore, remove any tags that are present on
-     * the newline that isn't going to be deleted after all (this simulates
-     * deleting the newline and then adding a "clean" one back again).
-     */
-
-    gint line1;
-    gint line2;
-
-    line1 = gtk_text_iter_get_line (start);
-    line2 = gtk_text_iter_get_line (end);
-
-    if (line2 == _gtk_text_btree_line_count (tree))
-      {
-        GtkTextTag** tags;
-        int array_size;
-        GtkTextIter orig_end;
-
-        orig_end = *end;
-        gtk_text_iter_backward_char (end);
-
-        --line2;
-
-        if (gtk_text_iter_get_line_offset (start) == 0 &&
-            line1 != 0)
-          {
-            gtk_text_iter_backward_char (start);
-            --line1;
-          }
-
-        tags = _gtk_text_btree_get_tags (end,
-                                         &array_size);
-
-        if (tags != NULL)
-          {
-            int i;
-
-            i = 0;
-            while (i < array_size)
-              {
-                _gtk_text_btree_tag (end, &orig_end, tags[i], FALSE);
-
-                ++i;
-              }
-
-            g_free (tags);
-          }
-      }
-  }
-
   /* Broadcast the need for redisplay before we break the iterators */
   _gtk_text_btree_invalidate_region (tree, start, end);
 
@@ -877,15 +819,21 @@ _gtk_text_btree_delete (GtkTextIter *start,
           if (deleted_width > 0 || deleted_height > 0)
             {
               ld = _gtk_text_line_get_data (start_line, view->view_id);
-
-              /* FIXME: ld is _NOT_ necessarily non-null here, but there is currently
-               * no way to add ld without also validating the node, which would
-               * be improper at this point.
-               */
-              /* This assertion does actually fail sometimes, must
-                 fix before stable release -hp */
-              g_assert (ld);
-
+              
+              if (ld == NULL)
+                {
+                  /* This means that start_line has never been validated.
+                   * We don't really want to do the validation here but
+                   * we do need to store our temporary sizes. So we
+                   * create the line data and assume a line w/h of 0.
+                   */
+                  ld = _gtk_text_line_data_new (view->layout, line);
+                  _gtk_text_line_add_data (line, ld);
+                  ld->width = 0;
+                  ld->height = 0;
+                  ld->valid = FALSE;
+                }
+              
               ld->width = MAX (deleted_width, ld->width);
               ld->height += deleted_height;
               ld->valid = FALSE;
@@ -3377,9 +3325,27 @@ _gtk_text_line_previous (GtkTextLine *line)
   return NULL;
 }
 
+
+GtkTextLineData*
+_gtk_text_line_data_new (GtkTextLayout *layout,
+                         GtkTextLine   *line)
+{
+  GtkTextLineData *line_data;
+
+  line_data = g_new (GtkTextLineData, 1);
+
+  line_data->view_id = layout;
+  line_data->next = NULL;
+  line_data->width = 0;
+  line_data->height = 0;
+  line_data->valid = FALSE;
+
+  return line_data;
+}
+
 void
 _gtk_text_line_add_data (GtkTextLine     *line,
-                        GtkTextLineData *data)
+                         GtkTextLineData *data)
 {
   g_return_if_fail (line != NULL);
   g_return_if_fail (data != NULL);
index 5b0b6c2b0cec746825e029a47b2b980fecdae23c..b3ae5fb93fdfca5435ad5be8f2f27587f748b5c8 100644 (file)
@@ -275,6 +275,8 @@ GtkTextLine    *    _gtk_text_line_previous_could_contain_tag (GtkTextLine
                                                                GtkTextBTree        *tree,
                                                                GtkTextTag          *tag);
 
+GtkTextLineData    *_gtk_text_line_data_new                   (GtkTextLayout     *layout,
+                                                               GtkTextLine       *line);
 
 /* Debug */
 void _gtk_text_btree_check (GtkTextBTree *tree);
index d6bfbd087791570748be70bc94617293957729f7..806d147f32165b77c3e9871c41fa810a92539083 100644 (file)
@@ -86,9 +86,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-static GtkTextLineData    *gtk_text_line_data_new                 (GtkTextLayout     *layout,
-                                                                   GtkTextLine       *line);
-
 static GtkTextLineData *gtk_text_layout_real_wrap (GtkTextLayout *layout,
                                                    GtkTextLine *line,
                                                    /* may be NULL */
@@ -925,7 +922,7 @@ gtk_text_layout_real_wrap (GtkTextLayout   *layout,
 
   if (line_data == NULL)
     {
-      line_data = gtk_text_line_data_new (layout, line);
+      line_data = _gtk_text_line_data_new (layout, line);
       _gtk_text_line_add_data (line, line_data);
     }
 
@@ -2036,24 +2033,6 @@ line_display_index_to_iter (GtkTextLayout      *layout,
   gtk_text_iter_forward_chars (iter, trailing);
 }
 
-/* FIXME: This really doesn't belong in this file ... */
-static GtkTextLineData*
-gtk_text_line_data_new (GtkTextLayout *layout,
-                        GtkTextLine   *line)
-{
-  GtkTextLineData *line_data;
-
-  line_data = g_new (GtkTextLineData, 1);
-
-  line_data->view_id = layout;
-  line_data->next = NULL;
-  line_data->width = 0;
-  line_data->height = 0;
-  line_data->valid = FALSE;
-
-  return line_data;
-}
-
 static void
 get_line_at_y (GtkTextLayout *layout,
                gint           y,